package Year22_Month06.day22;

public class 排序数组中两序之和 {
    //升序数组,第一想法:双指针
    public int[] twoSum(int[] numbers, int target) {
        int left = 0;
        int right = numbers.length - 1;
        while(left != right){
            if(numbers[left] + numbers[right] == target){
                break;
            }
            if(numbers[left] + numbers[right] > target){
                right--;
            }else{
                left++;
            }
        }
        return new int[]{left,right};
    }
}
